package com.oa.android.adapter;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.oa.android.R;
import com.oa.android.entry.GGao;
import com.oa.android.entry.Ric;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * 日程 on 2016/6/15.
 */
public class RicAdapter extends BaseAdapter {

    private Context context;
    private List<Ric> gaoList;

    public RicAdapter(Context context, List<Ric> list) {
        this.context = context;
        this.gaoList = list;
    }

    @Override
    public int getCount() {
        return gaoList.size();
    }


    @Override
    public Object getItem(int position) {
        return gaoList.get(position);
    }


    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.ric_item, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        Ric ric=gaoList.get(position);
        viewHolder.Title.setText(ric.getTITLE()+"");
        viewHolder.Content.setText(Html.fromHtml(ric.getCONTENT())+"");
        viewHolder.time.setText("开始："+ric.getBEGINTIME());
        viewHolder.person.setText("结束："+ric.getENDTIME());
        viewHolder.person.setTextSize(12.0f);
        viewHolder.sendP.setText("创建："+ric.getEMPNAME());
        if(ric.getIFSHARE().equals("0")){
            viewHolder.isGx.setText("已共享");
        }else{
            viewHolder.isGx.setText("未共享");
        }

        return convertView;
    }

    static class ViewHolder {
        @InjectView(R.id.Title)
        TextView Title;
        @InjectView(R.id.time)
        TextView time;
        @InjectView(R.id.Content)
        TextView Content;
        @InjectView(R.id.person)
        TextView person;
        @InjectView(R.id.isGx)
        TextView isGx;
        @InjectView(R.id.sendP)
        TextView sendP;

        ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }
    }
}
